﻿// -----------------------------------------------------------------------
// Copyright (c) David Kean. All rights reserved.
// -----------------------------------------------------------------------
extern alias pcl;
using System;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using pcl::System;

namespace Portable
{
    [TestClass]
    public class GlobalizationExtensionTests
    {
        [TestMethod]
        public void ToUpper_NullAsValue_ThrowsArgumentNull()
        {
            ExceptionAssert.ThrowsArgumentNull("value", () =>
            {
                GlobalizationExtensions.ToUpper((string)null, CultureInfo.CurrentCulture);
            });
        }

        [TestMethod]
        public void ToLower_NullAsValue_ThrowsArgumentNull()
        {
            ExceptionAssert.ThrowsArgumentNull("value", () =>
            {
                GlobalizationExtensions.ToLower((string)null, CultureInfo.CurrentCulture);
            });
        }

        [TestMethod]
        public void ToUpper_NullAsCulture_ThrowsArgumentNull()
        {
            ExceptionAssert.ThrowsArgumentNull("culture", () =>
            {
                GlobalizationExtensions.ToUpper("Value", (CultureInfo)null);
            });
        }

        [TestMethod]
        public void ToLower_NullAsCulture_ThrowsArgumentNull()
        {
            ExceptionAssert.ThrowsArgumentNull("culture", () =>
            {
                GlobalizationExtensions.ToLower("Value", (CultureInfo)null);
            });
        }

        [TestMethod]
        public void ToUpper_UsesCultureToUppercaseValue()
        {   // Simple tests just to verify that it's called ToUpper on the Culture's text info.
            // We assume that culture's upper case code actually works.

            var result = GlobalizationExtensions.ToUpper("i", new CultureInfo("tr-TR"));

            Assert.AreEqual(result, "İ");
        }

        [TestMethod]
        public void ToLower_UsesCultureToLowercaseValue()
        {
            // Simple tests just to verify that it's called ToUpper on the Culture's text info.
            // We assume that culture's upper case code actually works.

            var result = GlobalizationExtensions.ToLower("İ", new CultureInfo("tr-TR"));

            Assert.AreEqual(result, "i");
        }
    }
}
